package com.example.backadmindemo.controller;

import com.example.backadmindemo.pojo.BigEvent;
import com.example.backadmindemo.pojo.CustInfo;
import com.example.backadmindemo.service.BigEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class BigEventController {
    @Autowired
    private BigEventService bigEventService;

    @GetMapping("/selectNormal/{currentPage}/{pageSize}")
    public List<BigEvent> selectNormal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return bigEventService.selectNormal(currentPage, pageSize);
    }

    @GetMapping("/selectAbnormal/{currentPage}/{pageSize}")
    public List<BigEvent> selectAbnormal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return bigEventService.selectAbnormal(currentPage, pageSize);
    }

    @GetMapping("/getNormalSum")
    public Integer getNormalSum() {
        return bigEventService.getNormalSum();
    }

    @GetMapping("/getAbnormalSum")
    public Integer getAbnormalSum() {
        return bigEventService.getAbnormalSum();
    }

    @GetMapping("/setAbnormal/{id}")
    public void setAbnormal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        bigEventService.setAbnormal(realID);
    }

    @GetMapping("/cancelAbnormal/{id}")
    public void cancelAbnormal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        bigEventService.cancelAbnormal(realID);
    }
}
